package slhs.tempo.TableAnalyzer;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import slhs.tempo.scriptGenerator.UtilityConstants;

public class FilterControlsFrameHandler extends JFrame implements ActionListener, WindowListener {
    private FilterControlsPanelHandler filterControlsPanelHandler;
    private JPanel filterControlsPanel;
    private JScrollPane filterControlsScrollPane;
    private final TablePanelHandler tablePanelHandlerObject;

    public FilterControlsFrameHandler(TablePanelHandler tablePanelHandler) {
	this.tablePanelHandlerObject = tablePanelHandler;
	this.setTitle("Filter Controls");
	this.setBounds(UtilityConstants.FILTER_CONTROLS_FRAME_XPOSITION,
		UtilityConstants.FILTER_CONTROLS_FRAME_YPOSITION, UtilityConstants.FILTER_CONTROLS_FRAME_WIDTH,
		UtilityConstants.FILTER_CONTROLS_FRAME_HEIGHT);
	initConponents();
	addcomponents();
	// System.out.println("Creating new Filters frame");
    }

    /************************************************************************
     * Initialize Components method - start
     ************************************************************************/
    private void initConponents() {
	filterControlsScrollPane = new JScrollPane();
	filterControlsPanelHandler = new FilterControlsPanelHandler(this, tablePanelHandlerObject);
	filterControlsPanel = filterControlsPanelHandler.getPanel();
    }

    /************************************************************************
     * Initialize Components method - end
     ************************************************************************/

    /************************************************************************
     * Add components method- start
     ************************************************************************/

    private void addcomponents() {
	filterControlsScrollPane = new JScrollPane(filterControlsPanel);
	// filterControlsScrollPane.add(filterControlsPanel);
	this.add(filterControlsScrollPane);
	filterControlsPanel.revalidate();
	this.addWindowListener(this);
    }

    /************************************************************************
     * Add components method- end
     ************************************************************************/

    /************************************************************************
     * Event/Action listeners - start
     ************************************************************************/
    @Override
    public void actionPerformed(ActionEvent actionEvent) {
	// TODO Auto-generated method stub
	Object source = actionEvent.getSource();
    }

    @Override
    public void windowActivated(WindowEvent arg0) {
	// TODO Auto-generated method stub

    }

    @Override
    public void windowClosed(WindowEvent arg0) {
	// TODO Auto-generated method stub

    }

    @Override
    public void windowClosing(WindowEvent arg0) {
	System.out.println("Closing window");
	this.dispose();
	this.tablePanelHandlerObject.uncheckFiltersControlBox();
    }

    @Override
    public void windowDeactivated(WindowEvent arg0) {

    }

    @Override
    public void windowDeiconified(WindowEvent arg0) {

    }

    @Override
    public void windowIconified(WindowEvent arg0) {

    }

    @Override
    public void windowOpened(WindowEvent arg0) {

    }

    /************************************************************************
     * Event/Action listeners - End
     ************************************************************************/

}
